package com.ruoyi.controller;

import com.github.pagehelper.PageInfo;

import com.ruoyi.pojo.QuestionBank;
import com.ruoyi.service.QuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/question_bank")
public class QuestionBankController {
    @Autowired
    private QuestionBankService questionBankService;
//    查询
    @RequestMapping("/search")
    public PageInfo<QuestionBank> search(String name){
        return questionBankService.search(name);
    }
   @RequestMapping("/AddQuestion")
    public Boolean AddQuestion(@RequestBody QuestionBank questionBank){
       System.out.println(questionBank);
        return questionBankService.AddQuestion(questionBank);
    }
    @RequestMapping("findByQuestionBankName")
    public List<QuestionBank> findByQuestionBankName(String name){
        System.out.println(name);
        return questionBankService.findByQuestionBankName(name);
    }
    @RequestMapping("deleteQuestionBank")
    public Boolean deleteQuestionBank(Integer id){
        System.out.println(id);
        return questionBankService.deleteQuestionBank(id);
    }
    @RequestMapping("/updateQuestionBank")
    public Boolean updateQuestionBank(@RequestParam("id") Integer id,@RequestParam("bank_name") String bank_name,@RequestParam("creator") String creator){
        System.out.println(id+bank_name+creator);
        return questionBankService.updateQuestionBank(id,bank_name,creator);
    }
}
